\documentclass[11pt]{amsart}

%\usepackage{latexsym}
%\usepackage{amsbsy}
\usepackage[all]{xy}
%\usepackage{amscd}
\usepackage{amsmath,graphicx,amsthm,mathrsfs,verbatim,ifthen,enumerate,amssymb,
setspace}
\usepackage{comment}

\onehalfspacing

\textwidth = 6.5 in \textheight = 9.3 in \oddsidemargin = 0.0 in
\evensidemargin = 0.0 in \topmargin = -0.4 in \headheight = 0.2 in
\headsep = 0.2 in
\parskip = 0.2in
\parindent = 0.1in

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{corollary*}[theorem]{Corollary}
\newtheorem{proposition}[theorem]{Proposition}

\theoremstyle{definition}
\newtheorem{definition}{Definition}
\newtheorem{example}[definition]{Example}
\newtheorem{exercise}[definition]{Exercise}
\newtheorem{practice*}{Practice}

\theoremstyle{remark}
\newtheorem*{remark}{Remark}

\def\d{\displaystyle}
\newcommand{\bdef}{\begin{definition}}
\newcommand{\edefi}{\end{definition}}
\newcommand{\bexa}{\begin{example}}
\newcommand{\eexa}{\end{example}}
\newcommand{\bexe}{\begin{exercise}}
\newcommand{\eexe}{\end{exercise}}
\newcommand{\benu}{\begin{enumerate}}
\newcommand{\eenu}{\end{enumerate}}
\newcommand{\bite}{\begin{itemize}}
\newcommand{\eite}{\end{itemize}}
\newcommand{\brem}{\begin{remark}}
\newcommand{\erem}{\end{remark}}
\newcommand{\Ra}{\Rightarrow}
\newcommand{\Lra}{\Leftrightarrow}
\newcommand{\bpro}{\begin{proof}}
\newcommand{\epro}{\end{proof}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\bthe}{\begin{theorem}}
\newcommand{\ethe}{\end{theorem}}
\newcommand{\blank}[1]{\underline{\hspace{#1in}}}
\newcommand{\undr}{\underline}
\newcommand{\tb}{\textbf}


%\newcolumntype{M}{>{$}c<{$}}



\begin{document}

\title{MTH 1420, Spring 2012\\Dr. Graham-Squire}
\author{Lab 4: Approximate Integration }
\date{}
\maketitle

\tb{Names}: \blank{3}

\blank{3}

\blank{3}

\section{Introduction}

In this lab we look at ways of approximating integrals or using technology to calculate integrals.  As we have seen, integrals can be rather difficult to evaluate, and one often has to rely on tricks that will only work for a certain type of integral.  We will look at some ways of evaluating complicated integrals as well as approximating others.  We will not have a technique that works in all situations until later in the course, though, when we get to infinite series.

\section{Instructions}

\benu
	\item Introduce yourself to your lab partner(s).
	\item Work on the problems \undr{together with your partner} for the remainder of the lab time.  If you are confused about something, talk to your lab partner and explain your question to them to see if they can help.  If everyone in the group is stumped, come talk to me for a hint.  If you do not finish, it is okay to split up the remaining parts and work on them individually.  However, you should meet up sometime outside of class to check each other's work before you turn in a final draft next week. 
	\item Your group should write up and turn in \underline{one} completed lab at the start of the next lab period.  You can use this sheet as a cover sheet for the lab you turn in.  \tb{Each member of the group should write up at least part of the lab}, but you should check each other's work since everyone in the group gets the same score.  
\eenu

\section{Methods dealt with in this lab}

\bite
	\item Table of Integrals
	\item Computer Algebra Systems
	\item Approximate Integration
\eite


\section{Table of Integrals}

If you look at the back pages of your textbook, you will find reference pages with Differentiation Rules (page 5) and a table of integrals (page 6 onward).  
\bexe
Take a moment to glance at the number of differentiation rules compared with the length of the table of integrals.  What do you notice, and what does this imply about the relative difficulty of integration versus differentiation?
\eexe

In fact, many of the integrals in the table are just particular situations where you can use trigonometric substitution or integration by parts, and the table saves you the work of doing the steps.  Before computers and graphing calculators, this is how a lot of integration was done.  If you had a difficult integral, you would look at the table and see if you could match it to something.  Read page 395 for a couple of examples of how to do this (note that it will not always be a good match, and you may have to do some kind of substitution).

\bexe
	Use the table of integrals to evaluate $\d\int \sin^{-1}\sqrt{x}\, dx$.
\eexe


\section{Computer Algebra System}

We have already looked at the basics of integrating with Sage or a graphing calculator.  If you can't remember how it works, look up the instructions for Labs 1 and 2 on blackboard.
%Need to change these.
\bexe
	 
	\benu[(a)]
	\item 
	Use Sage, Maple or a TI-89 to evaluate:
	\benu[(i)] \item $\d\int \frac{1}{(x+2)(x+5)}\, dx$.
	\item $\d\int \frac{1}{(x+1)(x+2)}\, dx$.
	\item $\d\int \frac{1}{(x+2)(x-3)}\, dx$.
	\item $\d\int \frac{1}{(x+3)^2}\, dx$.
	\eenu
	\item Based on your answers from part (a), conjecture a general formula for $\d\int \frac{1}{(x+a)(x+b)}\, dx$, where $a$ and $b$ are real numbers.  
	\item Take the derivative of your answer in part (b) to confirm that it is correct.
	\item (Extra Credit) There should be some way to enter the integral from part (b) in Sage in order to get the general answer you found.  Figure out how to do it and explain the steps (you can either try to look it up on the internet or use Sage help.  To use the help in Sage, write the thing you want to figure out and put a question mark after it, then press tab).  
	
	
	\eenu
\eexe
\newpage


\bexe
	 
	\benu[(a)]
	\item 
	Use Sage, Maple or a TI-89 to evaluate:
	\benu[(i)] \item $\d\int xe^x\, dx$.
	\item $\d\int x^2e^x\, dx$.
	\item $\d\int x^3e^x\, dx$.
	\item $\d\int x^4e^x\, dx$.
	\item $\d\int x^5e^x\, dx$.
	\eenu
	\item Based on your answers from part (a), conjecture a general formula for $\d\int x^ne^x\, dx$, where $n$ is a positive integer.  
	\item Take the derivative of your answer in part (b) to confirm that it is correct.
	\item Use integration by parts on $\d\int x^ne^x\, dx$ to explain why your general formula from part (b) is correct (you may have to do integration by parts a couple of times to see the pattern emerge).  You should show your work, but also write a few sentences to explain what is going on.
	\eenu
\eexe

Although it is relatively straightforward to take derivatives of the standard functions (polynomials, trigonometric functions, logarithmic functions, etc), it is not the same with integration.  In fact, certain functions that have easy derivatives do not have antiderivatives at all (this depends on your definition of "antiderivative").  We will investigate a couple of these functions now, though we will not really be able to integrate them until near the end of the course.

\bexe
	\benu[(a)]
		\item Try to integrate $\d\int e^{x^2}\, dx$ by hand. 
		\item If you can integrate it, take the derivative to confirm that your answer is correct.  If you can't do it, explain why you think it is not working and then take the integral in Sage.  You should get some expressions that you have never seen before, in particular the ``erf" function.  Use the Sage help function to figure out what it means (that is, type in ``erf?" and see what it tells you.  You may need to look up some of the terms in Wikipedia as well).  
	\eenu
\eexe

\bexe
	\item Try to integrate $\d\int \cos (e^x) \, dx$ by hand.  If you can integrate it, take the derivative to confirm that your answer is correct.  If you can't do it, explain why you think it is not working and then take the integral in Sage.  You should get some expressions that you have never seen before.  Use the Sage help function to figure out what it means.
\eexe

\brem
	Not all of these unintegrables involve $e^x$.  Another example is $\d\int \frac{\sin x}{x}\, dx$.
\erem


\section{Approximate Integration}

We just saw that some relatively straightforward functions have no useful antiderivatives, so what do we do if we want to integrate one of them?  We can only approximate them once we are given limits of integration.  There are two important questions to ask in these situations:

\bite
	\item How fast do we get a good approximation (most of these will involve using computers, so we want to find an efficient approximation)?
	\item How good is the approximation (that is, how do we know when we are close enough to the real answer)?
\eite

\section{Riemann Sums}

Our first example of approximate integration is something we have already done, Riemann sums.  We used right, left and midpoints to do our calculations, and you may recall that midpoints tended to give us the best approximations.  We call this the ``Midpoint Rule", and we can actually use Sage to calculate it.

\bexe
	Use Sage to approximate  $\d\int^1_0 e^{x^2}\, dx$.  First use 15 subintervals, then do it with 100 subintervals.
	\benu
	\item Define your function $f$ with limits.  You do this by typing in 
	\[ \verb+f=Piecewise([[(0,1),e^{(x^2)})]])+
	\]
	\item Next get the Riemann sum approximation by doing
	\[ \verb+f.riemann_sum_integral_approximation(15,mode="midpoint")+
	\]
	You will notice that this might give you the exact values, which are not really useful.  To get a decimal answer, do
	\[\verb+ f.riemann_sum_integral_approximation(15,mode="midpoint").numerical_approx(100)+
	\]
	\item Now repeat step 2 with 100 subintervals. How different is your answer?
	\eenu
\eexe

\bexe
	Follow the steps above to approximate $\d\int^1_0 \cos(e^x)\, dx$.  First use 10 subintervals, then do it with 30 subintervals.
\eexe




\end{document} 